//
//  CMDBTagManager.swift
//  CMDB
//
//  Created by 王磊 on 17/4/14.
//  Copyright © 2017年 CMDB. All rights reserved.
//

import UIKit

class CMDBTagManager: NSObject {
    
    static let getInstance: CMDBTagManager = CMDBTagManager()
    
    private override init() {
        super.init()
        
    }
}
extension CMDBTagManager: CMDBTagManagerDelegate {}

extension CMDBTagManager {
    
    func queryAttributeTags(attributeTagParam: CMDBAttributeTagParam, handler: CMDBAttibuteTagsHandler, error: CMDBHttpErrorHandler, failure: CMDBHttpFailureHandler) {
        
        CMDBHttpManager.getInstance.request(attributeTagParam.URLString(), param: attributeTagParam.keyValues, success: { (sysTime, data, page) in
            
            let arr = CMDBAtibuteTagBean.objectArrayWithKeyValuesArray(data as! NSArray) as? Array<CMDBAtibuteTagBean>
            
            handler(attributeTags: arr)
            
            }, error: error, failure: failure)
        
    }
}

extension CMDBTagManager {
    
    func queryEntityTags(entityTagParam: CMDBEntityTagParam, handler: CMDBEntityTagsHandler, error: CMDBHttpErrorHandler, failure: CMDBHttpFailureHandler) {
        
        CMDBHttpManager.getInstance.request(entityTagParam.URLString(), param: entityTagParam.keyValues, success: { (sysTime, data, page) in
            
            let arr = CMDBEntityTagBean.objectArrayWithKeyValuesArray(data as! NSArray) as? Array<CMDBEntityTagBean>
            
            handler(entityTags: arr)
            
            }, error: error, failure: failure)
        
    }
}